package com.danicsoft.daide.token;


/**
 * Encapsulates a particular type of token. Any subclass of this class should
 * provide constants for all the subtypes of its particular type.
 * 
 * @author Daniel Yule (daniel.yule@gmail.com)
 * @version 1.0
 */
public abstract class TypeClass {

	@Override
	public String toString() {
		return getClass().getCanonicalName();
	}

	/**
	 * Returns true if the given token is of this type.
	 * 
	 * @param token
	 *        A <code>Token</code> to check.
	 * @return True if the token is of the type, false otherwise.
	 */
	public boolean isOfType(Token token) {
		byte Masked = (byte) (token.getType() & getMask());
		return (Masked) == getType();
	}

	/**
	 * Gets the type of this token
	 * 
	 * @return The token type.
	 */
	public abstract byte getType();

	/**
	 * Gets the mask for this particular type
	 * 
	 * @return A byte mask for this type.
	 */
	protected byte getMask() {
		return (byte) 0xFF;
	}

}
